﻿/**************************************************************************
创建日期:	2019/6/19 16:31:59     
作	  者:	张存
邮 	  箱:	zhangcunliang@126.com
创建时间:	
Copyright (c)  ZhCun.cn

描	述：
记	录：
***************************************************************************/
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace ZhCun.WebCommon
{
    /// <summary>
    /// Http 请求中间件
    /// </summary>
    public class ResetBodyMiddleware
    {
        /// <summary>
        /// 处理HTTP请求
        /// </summary>
        private readonly RequestDelegate next;

        /// <summary>
        /// 构造 Http 请求中间件
        /// </summary>
        /// <param name="next"></param>
        public ResetBodyMiddleware(RequestDelegate next)
        {
            this.next = next;
        }
        /// <summary>
        /// 执行响应流指向新对象
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task Invoke(HttpContext context)
        {
            //context.Response.Body = new ReadableResponseBody(context.Response.Body);
            await next.Invoke(context);            
        }
    }
}